﻿
namespace Comsenz.Discuz
{
    /// <summary>
    /// Discuz角色
    /// </summary>
    /// <author>Chiron</author>
    public class DiscuzRole
    {
        /// <summary>
        /// 构建Discuz角色
        /// </summary>
        /// <param name="name"></param>
        /// <param name="title"></param>
        internal DiscuzRole(string name, string title)
        {
            Name = name;
            Title = title;
        }
        /// <summary>
        /// 角色名
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// 显示名
        /// </summary>
        public string Title { get; private set; }
        /// <summary>
        /// 获取一个指示指定用户是否属于本角色的值。
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns></returns>
        public bool IsInRole(string username)
        {
            return DiscuzRoleManager.IsUserInRole(username, Name);
        }
        /// <summary>
        /// 获取属于本角色的用户的列表。
        /// </summary>
        /// <returns></returns>
        public string[] GetUsers()
        {
            return DiscuzRoleManager.GetUsersInRole(Name);
        }
    }
}
